/ Assembly List / LJCDBClientLib / DataManager / Load

Namespace - LJCDBClientLib


Parameters
keyColumns - The record containing the key field values.
propertyNames - The incuded column property names.
filters - The filter values.
joins - The join values.

Returns

The result object.

Syntax

C#
public DbResult Load(DbColumns keyColumns = null, List<String> propertyNames = null, DbFilters filters = null, DbJoins joins = null)

Retrieves a collection of data records. (DE)

Remarks

Parameters

keyColumns
This parameter defines the values to be used in the SQL where clause. It is only used if the 'filters' parameter is null.
The values are separated with the 'AND' operator.

propertyNames
This parameter defines the primary table columns that are to be included in the request. If it is null, then all the primary table columns are included.
It must not include Calculated or Join columns or it will cause an error.

filters
This parameter defines the values to be used in the SQL where clause. If it is defined, then the keyColumns parameter is not used.
The 'filters' object can define a complex where clause including combinations of 'AND' and 'OR' operators.

joins
The 'joins' parameter defines the join tables, join on values and join column definitions.

Creates a "Load" DbRequest object, which is available in the Request property. The request object is passed to the ExecuteRequest() method.

Request Column property names and values are added to the Result Value columns.

The Result Data Object property names must match the Result Value Column property names to map the values into the Result Data Object.

Result Data Object property names that are different from the Request Column names can be handled by setting the Request Column Property name. The MapNames() method is a helper method for setting the Property name.

Method Graph

All methods are in LJCDBMessage.DbCommon.

RequestColumns(baseDefinition)
RequestKeys(keyColumns)
CreateKeyColumn(keyColumn)

Example

C#
// This is an example of the Person Manager code that would access the
// DataManager Load() method. The supporting class code is listed at the
// DataManager class level.
    
using LJCNetCommon;
using LJCDBMessage;
    
/// <summary>Provides Person specific data manipulation methods.</summary>
public class PersonManager
{
  /// <summary>Retrieves a collection of Person records from the database.</summary>
  /// <param name="keyObject">The key record object.</param>
  /// <param name="propertyNames">The included column property names.</param>
  /// <param name="filters">The filter values.</param>
  /// <param name="dbJoins">The join values.</param>
  /// <returns>The Persons collection.</returns>
  public Persons Load(Person keyObject = null, List<string> propertyNames = null
    , DbFilters filters = null, DbJoins dbJoins = null)
  {
    Persons retValue = null;
    
    DbResult dbResult = mDataManager.Load(keyObject, propertyNames, filters, dbJoins);
    SQLStatement = mDataManager.SQLStatement;
    if (dbResult != null && dbResult.DbRecords.Count > 0)
    {
      // Populate a collection with the result records.
      retValue = CreateCollection(dbResult);
    }
    return retValue;
  }
    
  /// <summary>Creates a collection from the result object.</summary>
  /// <param name="dbResult">The result object.</param>
  /// <returns>The collection.</returns>
  private Persons CreateCollection(DbResult dbResult)
  {
    Persons retValue = new Persons();
    
    foreach (DbColumns dbColumns in dbResult.DbRecords)
    {
      Person person = new Person();
      DbCommon.SetObjectValues(dbColumns, person);
      retValue.Add(person);
    }
    return retValue;
  }
}

Copyright © Lester J. Clark and Contributors.
Licensed under the MIT License.